package com.tlgen.utils;

import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.List;

public class StringUtils {

    /**
     * 字符串设置首字母小写
     *
     * @param beanName
     * @return
     */
    public static String uncapFirst(String beanName) {
        beanName = beanName.substring(0, 1).toLowerCase().concat(beanName.substring(1));
        return beanName;
    }

    /**
     * 将 app-key 转换为 appKey
     *
     * @param str
     * @return
     */
    public static String formatSeparator(String str) {
        String[] split = str.split("-");
        List<String> strings = Lists.newArrayList();
        if (split.length == 0) return str;
        for (String s : split) {
            strings.add(s.substring(0, 1).toUpperCase().concat(s.substring(1)));
        }
        String join = String.join("", strings);
        String res = join.substring(0, 1).toLowerCase().concat(join.substring(1));
        return res;
    }

}
